<template>
	<view class="content">
		<view class="content_con">
			<view class="content_c">
				<lPainter :board="base" :isRenderImage="true" @success="save" />
				<!-- <image mode="aspectFill" :src="path"></image> -->
			</view>
			<view @click="saveImage" class="btnsave">保存</view>
		</view>
	</view>
</template>

<script>
import lPainter from '@/components/lime-painter/';
export default {
	components: { lPainter },
	data() {
		return {
			path: '',
			base: {
				width: '750rpx',
				height: '1300rpx',
				background: '#fff',
				views: [
					{
						type: 'image',
						src: '',
						mode: 'aspectFill',
						css: {
							width: '750rpx',
							height: '724px',
						},
					},

					{
						type: 'image',
						src: '',
						mode: 'widthFix',
						css: {
							left: '250rpx',
							top: '800rpx',
							width: '250rpx',
							height: '250rpx',
						},
					},
				],
			},
		};	
	},
	onLoad(e) {
		// let obj = JSON.parse(e.obj);
		// console.log(obj);
		// this.base.views[0].src = obj.course_img;
		// this.base.views[1].text = obj.nickname;
		// this.base.views[2].text = obj.title;
		// this.base.views[3].text = obj.lecturer;
		// this.base.views[4].src = obj.medal_img;
		// this.base.views[5].text = obj.create_time;
		// console.log("this.base.views[6].src: ",this.base.views[6].src);
		this.getLiveList();
		;
	},
	methods: {
		
		//init
		
		getLiveList(id) {
			this.$api('init').then(res => {
				
				 this.base.views[0].src =res.data.share.user_poster_bg
				 this.base.views[1].src =res.data.share.qrcode
				 console.log('this.base.views[0].src :>> ', this.base.views[0].src);
			});
		},
		
		
		
		async getThePoster() {
			
			const res = await this.$api.get({
				url: '/wanlshop/apizmk/init'
			});
			this.base.views[0].src = res[1].thumbnail_url
			console.log('res-------------------------------**** :>> ', this.base.views[0].src );
		},

		async get() {
			var id = uni.getStorageSync('wanlshop:user');
			this.$api.post({
				url: '/wanlshop/apizmk/wxacode1',
				data: {
					scene: id.id,
					page: 'pages/wanlshop/index'
				},
				success: res => {
					this.base.views[1].src = res;
					console.log('this.data :>> ', res);
				}
			});
		},
		save(path) {
			this.path = path;
			console.log(path);
			console.log(this.path);
		},
		saveImage() {
			this.isShowPopup = false;
			uni.saveImageToPhotosAlbum({
				filePath: this.path,
				success(res) {
					uni.showToast({
						title: '已保存到相册',
						icon: 'success',
						duration: 2000
					});
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	// position: fixed;
	// left: 0;
	// top: 0;
	width: 100vw;
	height: 100vh;
	// overflow: hidden;
	.content_con {
		width: 100%;
		height: 100%;
		background: #fff;
		.content_c {
			height: 100vh;
			width: 100vw;
			// position: absolute;
			// top: 0;
			// left: 0;
			// right: 0;
			// margin: auto;
			// bottom: 0;
			// image {
			// 	width: 100%;
			// 	height: 100%;
			// }
		}
		.btnsave {
			position: fixed;
			right: 0;
			bottom: 50rpx;
			z-index: 99999999999;
			width: 100%;
			height: 80rpx;
			background: rgba(6, 170, 110, 0.7);
			color: #fff;
			font-size: 28rpx;
			line-height: 80rpx;
			text-align: center;
		}
	}
}
</style>
